package org.example.custom.config;

import org.example.custom.utils.DatasourceContextHolder;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

//多数据源核心，自定义数据源读取路由
public class MyRoutingDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        //获取用户线程上下文中数据源
        return DatasourceContextHolder.getContext();
    }
}
